<?php
namespace app\admin\controller;

use app\common\model\CompanyBasicinfo as CompanybasicinfoModel;

/**
 * 寺院信息控制器
 * Class Company
 * @package app\index\controller
 */
class Companybasicinfo extends Base
{
    /**
     * [add  寺院信息添加]
     * @param
     * @return
     * @author [C。]
     */
    public function add()
    {
        $param = input('param.');
        $model = new CompanybasicinfoModel;
        $user = $this->user;
        try{
            if(empty($param['id'])){
                $id = $model->addData($param);
                $name = '添加';
            }else{
                $id = $model->editData($param);
                $name = '编辑';
            }
        }catch(\Exception $e){
            return admin_json(-1, '失败'.$e->getMessage());
        }
        writelog($name.'寺院信息--'.$id, 0,$user);
        return admin_json(1, $name.'成功');
    }
    /**
     * [get  获取寺院信息]
     * @param
     * @return
     * @author [C。]
     */
    public function get()
    {
        $param = input('param.');
        $model = new CompanybasicinfoModel;
        $user = $this->user;
        try{
            $data = $model->findData($param['comid'],'comid');
            if(!empty($data['img'])){
                $data['img'] = explode(',',$data['img']);
            }
        }catch(\Exception $e){
            return admin_json(-1, '获取失败'.$e->getMessage());
        }
        writelog('获取寺院信息--'.$param['comid'], 0,$user);
        return admin_json(1, '获取成功',$data);
    }
}